package com.gxa.service.baoBiaoService.impl;


import com.gxa.common.R;
import com.gxa.mapper.baobiaomapper.ZiJinBaoBiaoMapper;
import com.gxa.pojo.GouHuo;
import com.gxa.service.baoBiaoService.ZiJinBaoBiaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Service
public class ZiJinBaoBiaoServiceImpl implements ZiJinBaoBiaoService {

    @Autowired
    private ZiJinBaoBiaoMapper ziJinBaoBiaoMapper;

    @Override
    public R selectXianJinYingHang(String startTime, String endTime, String zhangHuId) {
        R r=new R();

        HashMap<Object, Object> map = new HashMap<>();
        map.put("收款单",ziJinBaoBiaoMapper.selectXianJinYingHangForShouKuanDan(startTime, endTime ,  zhangHuId));
        map.put("付款单",ziJinBaoBiaoMapper.selectXianJinYingHangForFuKuanDan(startTime, endTime ,  zhangHuId));
        map.put("采购单",ziJinBaoBiaoMapper.selectXianJinYingHangForGouHuo(startTime, endTime ,  zhangHuId));
        map.put("销货单",ziJinBaoBiaoMapper.selectXianJinYingHangForXiaoHuoDan(startTime, endTime ,  zhangHuId));

        r.setCode(200);
        r.setMsg("现金银行查询成功！");
        r.setData(map);

        return r;

    }

    @Override
    public R selectYingFuZhangKuanMingXi(String startTime, String endTime, String gongYingShangId) {
        R r=new R();
        List<GouHuo> list = new ArrayList<>();
        list=ziJinBaoBiaoMapper.selectYingFuZhangKuanMingXi(startTime, endTime ,  gongYingShangId);
        r.setCode(200);
        r.setMsg("应付账款明细查询成功！");
        r.setData(list);

        return r;
    }

    @Override
    public R selectYingShouZhangKuanMingXi(String startTime, String endTime, String keHuId) {
        R r=new R();
        HashMap<Object, Object> map = new HashMap<>();
        map.put("销货单",ziJinBaoBiaoMapper.selectYingShouZhangKuanMingXiForXiaoHuoDan(startTime, endTime ,  keHuId));
        map.put("收款单",ziJinBaoBiaoMapper.selectYingShouZhangKuanMingXiForShouKuanDan(startTime, endTime ,  keHuId));
        r.setCode(200);
        r.setMsg("应收账款明细查询成功！");
        r.setData(map);

        return r;
    }

    @Override
    public R selectKeHuDuiZhangDan(String startTime, String endTime, String keHuId) {
        R r=new R();
        HashMap<Object, Object> map = new HashMap<>();
        map.put("收款单",ziJinBaoBiaoMapper.selectKeHuDuiZhangDanForShouKuanDan(startTime, endTime ,  keHuId));
        map.put("付款单",ziJinBaoBiaoMapper.selectKeHuDuiZhangDanForXiaoShouDan(startTime, endTime ,  keHuId));
        r.setCode(200);
        r.setMsg("客户对账单查询成功！");
        r.setData(map);

        return r;
    }

    @Override
    public R selectGongYingShangDuiZhangDan(String startTime, String endTime, String gongYingShangId) {
        R r=new R();
        HashMap<Object, Object> map = new HashMap<>();
        map.put("购货单",ziJinBaoBiaoMapper.selectGongYingShangDuiZhangDanForGouHuo(startTime, endTime ,  gongYingShangId));
        map.put("付款单",ziJinBaoBiaoMapper.selectGongYingShangDuiZhangDanForFuKuanDan(startTime, endTime ,  gongYingShangId));

        r.setCode(200);
        r.setMsg("供应商对账单查询成功！");
        r.setData(map);

        return r;
    }
}
